import 'dart:convert' show json;

class MusicRank {
  int code;
  String message;
  List<RankType> result;

  MusicRank.fromParams({this.code, this.message, this.result});

  factory MusicRank(jsonStr) => jsonStr == null
      ? null
      : jsonStr is String
          ? new MusicRank.fromJson(json.decode(jsonStr))
          : new MusicRank.fromJson(jsonStr);

  MusicRank.fromJson(jsonRes) {
    code = jsonRes['code'];
    message = jsonRes['message'];
    result = jsonRes['result'] == null ? null : [];

    for (var resultItem in result == null ? [] : jsonRes['result']) {
      result.add(resultItem == null ? null : new RankType.fromJson(resultItem));
    }
  }

  @override
  String toString() {
    return '{"code": $code,"message": ${message != null ? '${json.encode(message)}' : 'null'},"result": $result}';
  }
}

class RankType {
  int count;
  int type;
  String bg_color;
  String bg_pic;
  String color;
  String comment;
  String name;
  String pic_s192;
  String pic_s210;
  String pic_s260;
  String pic_s444;
  String web_url;
  List<RankItem> content;

  RankType.fromParams(
      {this.count,
      this.type,
      this.bg_color,
      this.bg_pic,
      this.color,
      this.comment,
      this.name,
      this.pic_s192,
      this.pic_s210,
      this.pic_s260,
      this.pic_s444,
      this.web_url,
      this.content});

  RankType.fromJson(jsonRes) {
    count = jsonRes['count'];
    type = jsonRes['type'];
    bg_color = jsonRes['bg_color'];
    bg_pic = jsonRes['bg_pic'];
    color = jsonRes['color'];
    comment = jsonRes['comment'];
    name = jsonRes['name'];
    pic_s192 = jsonRes['pic_s192'];
    pic_s210 = jsonRes['pic_s210'];
    pic_s260 = jsonRes['pic_s260'];
    pic_s444 = jsonRes['pic_s444'];
    web_url = jsonRes['web_url'];
    content = jsonRes['content'] == null ? null : [];

    for (var contentItem in content == null ? [] : jsonRes['content']) {
      content
          .add(contentItem == null ? null : new RankItem.fromJson(contentItem));
    }
  }

  @override
  String toString() {
    return '{"count": $count,"type": $type,"bg_color": ${bg_color != null ? '${json.encode(bg_color)}' : 'null'},"bg_pic": ${bg_pic != null ? '${json.encode(bg_pic)}' : 'null'},"color": ${color != null ? '${json.encode(color)}' : 'null'},"comment": ${comment != null ? '${json.encode(comment)}' : 'null'},"name": ${name != null ? '${json.encode(name)}' : 'null'},"pic_s192": ${pic_s192 != null ? '${json.encode(pic_s192)}' : 'null'},"pic_s210": ${pic_s210 != null ? '${json.encode(pic_s210)}' : 'null'},"pic_s260": ${pic_s260 != null ? '${json.encode(pic_s260)}' : 'null'},"pic_s444": ${pic_s444 != null ? '${json.encode(pic_s444)}' : 'null'},"web_url": ${web_url != null ? '${json.encode(web_url)}' : 'null'},"content": $content}';
  }
}

class RankItem {
  String album_id;
  String album_title;
  String all_rate;
  String author;
  String biaoshi;
  String pic_big;
  String pic_small;
  String rank_change;
  String song_id;
  String title;

  RankItem.fromParams(
      {this.album_id,
      this.album_title,
      this.all_rate,
      this.author,
      this.biaoshi,
      this.pic_big,
      this.pic_small,
      this.rank_change,
      this.song_id,
      this.title});

  RankItem.fromJson(jsonRes) {
    album_id = jsonRes['album_id'];
    album_title = jsonRes['album_title'];
    all_rate = jsonRes['all_rate'];
    author = jsonRes['author'];
    biaoshi = jsonRes['biaoshi'];
    pic_big = jsonRes['pic_big'];
    pic_small = jsonRes['pic_small'];
    rank_change = jsonRes['rank_change'];
    song_id = jsonRes['song_id'];
    title = jsonRes['title'];
  }

  @override
  String toString() {
    return '{"album_id": ${album_id != null ? '${json.encode(album_id)}' : 'null'},"album_title": ${album_title != null ? '${json.encode(album_title)}' : 'null'},"all_rate": ${all_rate != null ? '${json.encode(all_rate)}' : 'null'},"author": ${author != null ? '${json.encode(author)}' : 'null'},"biaoshi": ${biaoshi != null ? '${json.encode(biaoshi)}' : 'null'},"pic_big": ${pic_big != null ? '${json.encode(pic_big)}' : 'null'},"pic_small": ${pic_small != null ? '${json.encode(pic_small)}' : 'null'},"rank_change": ${rank_change != null ? '${json.encode(rank_change)}' : 'null'},"song_id": ${song_id != null ? '${json.encode(song_id)}' : 'null'},"title": ${title != null ? '${json.encode(title)}' : 'null'}}';
  }
}
